home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / ip / manage / snmp / kip / ie.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-17  |  7.2 KB  |  241 lines

  1. /*
  2.  *  Intel 82586 registers and structures.
  3.  *
  4.  *  (c) 1984, Stanford Univ. SUMEX project.
  5.  *  May be used but not sold without permission.
  6.  *
  7.  *  (c) 1986, Kinetics, Inc.
  8.  *  May be used but not sold without permission.
  9.  *
  10.  */
  11.  
  12. /*
  13.  * Byte Swapping explained:
  14.  *    When data is accessed a character at a time there is no
  15.  *    problem, but when data is accessed as a short (2 bytes)
  16.  *    or a long (4 bytes), the 68000 and the i82586 have
  17.  *    different ways of ordering the bytes. The 68000 accesses
  18.  *    the most significant byte as the even address and the
  19.  *    i82586 accesses the least significant byte as the even
  20.  *    address. Therefore, every read/write of shorts and longs
  21.  *    must be reversed end-to-end by the 68000. All this boils
  22.  *    down to the point that the following structure declarations
  23.  *    look just like the way they are documented in the Intel manuals,
  24.  *    but because those structures contain 16- and 32-bit fields,
  25.  *    conversion must be done by the 68000 on all read/writes to
  26.  *    those fields. This way data is always correct for the i82596.
  27.  *    When OR'ing and AND'ing, don't forget that the data in the
  28.  *    structures is already "swapped" as it were.
  29.  */
  30.  
  31. /*
  32.  * buffer descriptor.
  33.  */
  34. struct bd {
  35.     u_short    bd_count;    /* data count */
  36.     u_short    bd_next;    /* link to next */
  37.     u_short    bd_buf;        /* buffer pointer */
  38.     u_short    bd_bufhi;
  39.     u_short    bd_size;    /* buffer size (rbd only) */
  40. };
  41.  
  42. /* bd_count */
  43. #define    BD_EOF        0x8000    /* end of frame */
  44. #define    BD_F        0x4000    /* filled by 82586 */
  45. #define    BD_COUNT    0x3FFF    /* count field */
  46. /* bd_size */
  47. #define    BD_EL        0x8000    /* end of list */
  48.  
  49. /*
  50.  * transmit buffer
  51.  */
  52. struct t_bd {
  53.     struct bd tbd;        /* the buffer descriptor */
  54.     struct pbuf *tpbuf;    /* address of the pbuf used for transmit data */
  55. };
  56.  
  57. /*
  58.  * receive buffer
  59.  */
  60. struct r_bd {
  61.     struct bd rbd;        /* the buffer descriptor */
  62.     struct pbuf *rpbuf;    /* address of the pbuf used for receive data */
  63. };
  64.  
  65. /*
  66.  * Command block / receive frame descriptor.
  67.  */
  68. struct cb {
  69.     u_short    cb_status;    /* status */
  70.     u_short    cb_cmd;        /* command */
  71.     u_short    cb_link;    /* link to next */
  72.     u_short    cb_param[6];    /* different parameters here */
  73. };
  74.  
  75. /* cb_status */
  76. #define    CB_COMPLETE    0x8000    /* complete */
  77. #define    CB_BUSY        0x4000    /* busy */
  78. #define    CB_OK        0x2000    /* ok */
  79. #define    CB_ABORT    0x1000    /* aborted */
  80. /* cb_cmd */
  81. #define    CB_EL        0x8000    /* end of list */
  82. #define    CB_S        0x4000    /* suspend */
  83. #define    CB_I        0x2000    /* hardware interrupt when done */
  84. /* cb_link */
  85. #define    CB_NIL        0xffff    /* empty pointer */
  86. /* action commands */
  87. #define    CBC_NOP        0    /* no operation */
  88. #define    CBC_IASETUP    1    /* individual address setup */
  89. #define    CBC_CONFIG    2    /* configure */
  90. #define CBC_MULTICAST    3    /* Set multicast address(es) */
  91. #define    CBC_TRANS    4    /* transmit */
  92. #define CBC_TDR         5       /* Time Domain Reflectometer */
  93. #define    CBC_DUMP    6    /* dump internal regs */
  94. #define CBC_DIAGNOSE    7    /* Diagnose */
  95.  
  96. /*
  97.  * frame descriptor structure
  98.  */
  99. struct fdes {
  100.     u_short    fd_status;    /* status */
  101.     u_short    fd_stat2;    /* 2 more stat bits */
  102.     u_short    fd_link;    /* link offset */
  103.     u_short fd_rbd;        /* rbd offset */
  104.     u_char    fd_daddr[6];    /* destination address */
  105.     u_char    fd_saddr[6];    /* source address */
  106.     u_short    fd_type;    /* type field of received frame */
  107. };
  108.  
  109. /* fd_status */
  110. #define    FD_C        0x8000    /* complete */
  111. #define    FD_B        0x4000    /* busy */
  112. #define    FD_OK        0x2000    /* frame completed ok */
  113. /* fd_stat2 */
  114. #define    FD_EL        0x8000    /* end of list */
  115. #define    FD_S        0x4000    /* suspend after receive */
  116. /* fd_rbd */
  117. #define    FD_NIL        0xffff    /* empty pointer */
  118.  
  119. /*
  120.  * System control block, plus some driver static structures.
  121.  */
  122. struct scb {
  123.     u_short    sc_status;    /* status */
  124.     u_short    sc_cmd;        /* command */
  125.     u_short    sc_clist;    /* command list */
  126.     u_short    sc_rlist;    /* receive frame list */
  127.     u_short    sc_crcerrs;    /* crc errors */
  128.     u_short    sc_alnerrs;    /* alignment errors */
  129.     u_short    sc_rscerrs;    /* resource errors (lack of rfd/rbd's) */
  130.     u_short    sc_ovrnerrs;    /* overrun errors (mem bus not avail) */
  131. };
  132.  
  133. /* sc_status bits set by 82586 */
  134. #define    STAT_CX        0x8000    /* command executed */
  135. #define    STAT_FR        0x4000    /* frame received */
  136. #define    STAT_CNA    0x2000    /* cmd unit went active */
  137. #define    STAT_RNR    0x1000    /* rec unit left ready */
  138. #define    STAT_IDLE    0x0000    /* no status bits */
  139.  
  140. /* sc_cmd bits ack'd by CPU */
  141. #define    ACK_CX        0x8000    /* command executed */
  142. #define    ACK_FR        0x4000    /* frame received */
  143. #define    ACK_CNA        0x2000    /* cmd unit went active */
  144. #define    ACK_RNR        0x1000    /* rec unit left ready */
  145. #define    ACK_NONE    0x0000    /* no status bits */
  146.  
  147. /* command unit status */
  148. #define    CUS_IDLE    0x000    /* idle */
  149. #define    CUS_SUSP    0x100    /* suspended */
  150. #define    CUS_ACTIVE    0x200    /* ready */
  151. #define    SC_CUS        0x700    /* command unit status field */
  152.  
  153. /* receive unit status */
  154. #define    RUS_IDLE    0x0    /* idle */
  155. #define    RUS_SUSP    0x10    /* suspended */
  156. #define    RUS_NORES    0x20    /* no resources */
  157. #define    RUS_READY    0x40    /* ready */
  158. #define    SC_RUS        0x70    /* receive unit status field */
  159.  
  160. /* command unit commands */
  161. #define    CUC_NOP        0x000    /* nop */
  162. #define    CUC_START    0x100    /* start */
  163. #define    CUC_RES        0x200    /* resume */
  164. #define    CUC_SUSP    0x300    /* suspend */
  165. #define    CUC_ABORT    0x400    /* abort */
  166.  
  167. /* receive unit commands */
  168. #define    RUC_NOP        0x00    /* nop */
  169. #define    RUC_START    0x10    /* start */
  170. #define    RUC_RES        0x20    /* resume */
  171. #define    RUC_SUSP    0x30    /* suspend */
  172. #define    RUC_ABORT    0x40    /* abort */
  173.  
  174. /* odd man out */
  175. #define    SC_RESET    0x0080    /* software reset */
  176.  
  177. /*
  178.  * intermediate system configuration pointer
  179.  */
  180. struct iscp {
  181.     u_char    is_busy;    /* lo order byte is busy byte */
  182.     u_char    is_test;    /* byte used in testing */
  183.     u_short is_scb_off;    /* lo order 16 bits of scb address */
  184.                 /* base for scb and all other types of blocks */
  185.     u_short    is_lo_scb_base;    /* lo order 16 bits of scb base */
  186.     u_short    is_hi_scb_base;    /* hi order 8 bits of scb base (in lsb) */
  187. };
  188. #define    ISCPBUSY    0x01    /* cleared by 82586 when reset accepted */
  189.  
  190. /*
  191.  * system configuration pointer
  192.  * 10 (decimal) bytes from 0xFFFFF6 to 0xFFFFFF
  193.  */
  194. struct scp {
  195.     u_short    scp_sysbus;    /* lo order byte is sysbus byte */
  196.     u_short    scp_sp1;    /* unused */
  197.     u_short scp_sp2;    /* unused by 82586 but used by 68000 */
  198.     u_short    scp_lo_iscp;    /* lo order 16 bits of iscp address */
  199.     u_short    scp_hi_iscp;    /* hi order 8 bits of iscp address (in lsb) */
  200. };
  201. #define    SYSBUS_8    0x01    /* indicates 8-bit bus in scp_sysbus */
  202. #define    SYSBUS_16    0x00    /* indicates 16-bit bus in scp_sysbus */
  203.  
  204. /*
  205.  * macros to extract address pieces...
  206.  */
  207. #define    HI16(addr)    ((short)(((int)(addr)) >> 16) & 0xffff)
  208. #define    LO16(addr)    ((short)((int)(addr)) & 0xffff)
  209.  
  210. /*
  211.  * swap bytes in a 16-bit value at compile time whenever possible
  212.  */
  213. #define    SWAB(jj)    (((jj & 0xff) << 8) | ((jj & 0xff00) >> 8))
  214.  
  215. struct    iscp    k_iscp;
  216. struct     scb    k_scb;
  217. struct      cb    k_cb;
  218. struct    fdes    k_fdes;
  219.  
  220. #define    SCPADDR        ((struct  scp *) 0xfffff6)
  221. #define    ISCPADDR    (&k_iscp)
  222. /*
  223.  * base address for scb, command and receive frame descriptor blocks
  224.  */
  225. #ifdef SMARTLINK
  226. #define    SCBBASE        ((int)&k_scb & 0xff0000)
  227. #define    SCBADDR        ((struct  scb *)(SCBBASE + LO16(&k_scb)))
  228. #define    CMDADDR        ((struct   cb *)(SCBBASE + LO16(&k_cb)))
  229. #define    FDESADDR    ((struct fdes *)(SCBBASE + LO16(&k_fdes)))
  230. #else
  231. #define    SCBBASE scbbase
  232. #define    SCBADDR scbaddr
  233. #define    CMDADDR cmdaddr
  234. #define    FDESADDR fdesaddr
  235. #endif
  236. /*
  237.  * convert an i82586 16-bit offset to a 68000 24-bit address
  238.  */
  239. #define    OTOA(type,off)    ((type)(SCBBASE + SWAB(off)))
  240.  
  241.